import java.util.Scanner;

public class demo06 {
    public static int n=4;
    public static int count=0;
    public static int[] dx={0,1,0,-1};
    public static int[] dy={1,0,-1,0};
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int[][] arr=new int[n][n];
                int index=1;
                arr[i][j]=1;
                dfs(arr,i,j,index);
            }
        }
        System.out.println(count);
    }
    public static void dfs(int[][] arr,int i,int j,int index){
        if(index==n*n){
            count++;
            return;
        }
        for (int k = 0; k < 4; k++) {
            int i1=i+dx[k];
            int j1=j+dy[k];
            if(i1>=0&&i1<4&&j1>=0&&j1<4){
                if(arr[i1][j1]==0){
                    arr[i1][j1]=index+1;
                    dfs(arr,i1,j1,index+1);
                    arr[i1][j1]=0;
                }
            }
        }
    }
}
